package com.ruoyi.appreciate.competition.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.appreciate.competition.mapper.CompetitionMapper;
import com.ruoyi.appreciate.competition.domain.Competition;
import com.ruoyi.appreciate.competition.service.ICompetitionService;

/**
 * 书法赛事Service业务层处理
 * 
 * @author duanxinli
 * @date 2025-10-11
 */
@Service
public class CompetitionServiceImpl implements ICompetitionService 
{
    @Autowired
    private CompetitionMapper competitionMapper;

    /**
     * 查询书法赛事
     * 
     * @param id 书法赛事主键
     * @return 书法赛事
     */
    @Override
    public Competition selectCompetitionById(String id)
    {
        return competitionMapper.selectCompetitionById(id);
    }

    /**
     * 查询书法赛事列表
     * 
     * @param competition 书法赛事
     * @return 书法赛事
     */
    @Override
    public List<Competition> selectCompetitionList(Competition competition)
    {
        return competitionMapper.selectCompetitionList(competition);
    }

    /**
     * 新增书法赛事
     * 
     * @param competition 书法赛事
     * @return 结果
     */
    @Override
    public int insertCompetition(Competition competition)
    {
        competition.setId(IdUtils.fastUUID());
        competition.setCreateDate(DateUtils.getNowDate());
        String username = SecurityUtils.getUsername();
        competition.setCreateBy(username);
        competition.setSort(0L);
        competition.setDelFlag(0L);
        return competitionMapper.insertCompetition(competition);
    }

    /**
     * 修改书法赛事
     * 
     * @param competition 书法赛事
     * @return 结果
     */
    @Override
    public int updateCompetition(Competition competition)
    {
        return competitionMapper.updateCompetition(competition);
    }

    /**
     * 批量删除书法赛事
     * 
     * @param ids 需要删除的书法赛事主键
     * @return 结果
     */
    @Override
    public int deleteCompetitionByIds(String[] ids)
    {
        return competitionMapper.deleteCompetitionByIds(ids);
    }

    /**
     * 删除书法赛事信息
     * 
     * @param id 书法赛事主键
     * @return 结果
     */
    @Override
    public int deleteCompetitionById(String id)
    {
        return competitionMapper.deleteCompetitionById(id);
    }
}
